package com.example.hanfu;

import android.os.Bundle;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

public class ViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view);

        ViewPager2 viewPager=findViewById(R.id.viewPage2);
        MyPageAdapter pageAdapter=new MyPageAdapter(ViewActivity.this);
        viewPager.setAdapter(pageAdapter);
        TabLayout tabLayout = findViewById(R.id.tab_layout);
        String a[]=new String[4];
        a[0]="推荐";
        a[1]="专题";
        a[2]="汉服题库";
        a[3]="个人主页";
        new TabLayoutMediator(tabLayout, viewPager,
                (tab, position) -> tab.setText(a[position])
        ).attach();




}
}
